home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / Mesa-3.0 / SRC-GLUT / GLUTINT.H < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-01  |  26.3 KB  |  735 lines

  1. #ifndef __glutint_h__
  2. #define __glutint_h__
  3.  
  4. /* Copyright (c) Mark J. Kilgard, 1994, 1997, 1998. */
  5.  
  6. /* This program is freely distributable without licensing fees
  7.    and is provided without guarantee or warrantee expressed or
  8.    implied. This program is -not- in the public domain. */
  9.  
  10. #if defined(__CYGWIN32__)
  11. #include <sys/time.h>
  12. #endif
  13.  
  14. #if defined(_WIN32)
  15. #include "glutwin32.h"
  16. #else
  17. #ifdef __sgi
  18. #define SUPPORT_FORTRAN
  19. #endif
  20. #include <X11/Xlib.h>
  21. #include <X11/Xutil.h>
  22. #include <GL/glx.h>
  23. #endif
  24.  
  25. #include <stdlib.h>
  26. #include <GL/glut.h>
  27.  
  28. /* Non-Win32 platforms need APIENTRY defined to nothing
  29.    because all the GLUT routines have the APIENTRY prefix
  30.    to make Win32 happy. */
  31. #ifndef APIENTRY
  32. #define APIENTRY
  33. #endif
  34.  
  35. #ifdef __vms
  36. #if ( __VMS_VER < 70000000 )
  37. struct timeval {
  38.   __int64 val;
  39. };
  40. extern int sys$gettim(struct timeval *);
  41. #else
  42. #include <time.h>
  43. #endif
  44. #else
  45. #include <sys/types.h>
  46. #if !defined(_WIN32)
  47. #include <sys/time.h>
  48. #else
  49. #include <winsock.h>
  50. #endif
  51. #endif
  52. #if defined(__vms) && ( __VMS_VER < 70000000 )
  53.  
  54. /* For VMS6.2 or lower :
  55.    One TICK on VMS is 100 nanoseconds; 0.1 microseconds or
  56.    0.0001 milliseconds. This means that there are 0.01
  57.    ticks/ns, 10 ticks/us, 10,000 ticks/ms and 10,000,000
  58.    ticks/second. */
  59.  
  60. #define TICKS_PER_MILLISECOND 10000
  61. #define TICKS_PER_SECOND      10000000
  62.  
  63. #define GETTIMEOFDAY(_x) (void) sys$gettim (_x);
  64.  
  65. #define ADD_TIME(dest, src1, src2) { \
  66.   (dest).val = (src1).val + (src2).val; \
  67. }
  68.  
  69. #define TIMEDELTA(dest, src1, src2) { \
  70.   (dest).val = (src1).val - (src2).val; \
  71. }
  72.  
  73. #define IS_AFTER(t1, t2) ((t2).val > (t1).val)
  74.  
  75. #define IS_AT_OR_AFTER(t1, t2) ((t2).val >= (t1).val)
  76.  
  77. #else
  78. #if defined(SVR4) && !defined(sun)  /* Sun claims SVR4, but
  79.                                        wants 2 args. */
  80. #define GETTIMEOFDAY(_x) gettimeofday(_x)
  81. #else
  82. #define GETTIMEOFDAY(_x) gettimeofday(_x, NULL)
  83. #endif
  84. #define ADD_TIME(dest, src1, src2) { \
  85.   if(((dest).tv_usec = \
  86.     (src1).tv_usec + (src2).tv_usec) >= 1000000) { \
  87.     (dest).tv_usec -= 1000000; \
  88.     (dest).tv_sec = (src1).tv_sec + (src2).tv_sec + 1; \
  89.   } else { \
  90.     (dest).tv_sec = (src1).tv_sec + (src2).tv_sec; \
  91.     if(((dest).tv_sec >= 1) && (((dest).tv_usec <0))) { \
  92.       (dest).tv_sec --;(dest).tv_usec += 1000000; \
  93.     } \
  94.   } \
  95. }
  96. #define TIMEDELTA(dest, src1, src2) { \
  97.   if(((dest).tv_usec = (src1).tv_usec - (src2).tv_usec) < 0) { \
  98.     (dest).tv_usec += 1000000; \
  99.     (dest).tv_sec = (src1).tv_sec - (src2).tv_sec - 1; \
  100.   } else { \
  101.      (dest).tv_sec = (src1).tv_sec - (src2).tv_sec; \
  102.   } \
  103. }
  104. #define IS_AFTER(t1, t2) \
  105.   (((t2).tv_sec > (t1).tv_sec) || \
  106.   (((t2).tv_sec == (t1).tv_sec) && \
  107.   ((t2).tv_usec > (t1).tv_usec)))
  108. #define IS_AT_OR_AFTER(t1, t2) \
  109.   (((t2).tv_sec > (t1).tv_sec) || \
  110.   (((t2).tv_sec == (t1).tv_sec) && \
  111.   ((t2).tv_usec >= (t1).tv_usec)))
  112. #endif
  113.  
  114. #define IGNORE_IN_GAME_MODE() \
  115.   { if (__glutGameModeWindow) return; }
  116.  
  117. #define GLUT_WIND_IS_RGB(x)         (((x) & GLUT_INDEX) == 0)
  118. #define GLUT_WIND_IS_INDEX(x)       (((x) & GLUT_INDEX) != 0)
  119. #define GLUT_WIND_IS_SINGLE(x)      (((x) & GLUT_DOUBLE) == 0)
  120. #define GLUT_WIND_IS_DOUBLE(x)      (((x) & GLUT_DOUBLE) != 0)
  121. #define GLUT_WIND_HAS_ACCUM(x)      (((x) & GLUT_ACCUM) != 0)
  122. #define GLUT_WIND_HAS_ALPHA(x)      (((x) & GLUT_ALPHA) != 0)
  123. #define GLUT_WIND_HAS_DEPTH(x)      (((x) & GLUT_DEPTH) != 0)
  124. #define GLUT_WIND_HAS_STENCIL(x)    (((x) & GLUT_STENCIL) != 0)
  125. #define GLUT_WIND_IS_MULTISAMPLE(x) (((x) & GLUT_MULTISAMPLE) != 0)
  126. #define GLUT_WIND_IS_STEREO(x)      (((x) & GLUT_STEREO) != 0)
  127. #define GLUT_WIND_IS_LUMINANCE(x)   (((x) & GLUT_LUMINANCE) != 0)
  128. #define GLUT_MAP_WORK               (1 << 0)
  129. #define GLUT_EVENT_MASK_WORK        (1 << 1)
  130. #define GLUT_REDISPLAY_WORK         (1 << 2)
  131. #define GLUT_CONFIGURE_WORK         (1 << 3)
  132. #define GLUT_COLORMAP_WORK          (1 << 4)
  133. #define GLUT_DEVICE_MASK_WORK        (1 << 5)
  134. #define GLUT_FINISH_WORK        (1 << 6)
  135. #define GLUT_DEBUG_WORK            (1 << 7)
  136. #define GLUT_DUMMY_WORK            (1 << 8)
  137. #define GLUT_FULL_SCREEN_WORK       (1 << 9)
  138. #define GLUT_OVERLAY_REDISPLAY_WORK (1 << 10)
  139. #define GLUT_REPAIR_WORK            (1 << 11)
  140. #define GLUT_OVERLAY_REPAIR_WORK    (1 << 12)
  141.  
  142. /* Frame buffer capability macros and types. */
  143. #define RGBA                    0
  144. #define BUFFER_SIZE             1
  145. #define DOUBLEBUFFER            2
  146. #define STEREO                  3
  147. #define AUX_BUFFERS             4
  148. #define RED_SIZE                5  /* Used as mask bit for
  149.                                       "color selected". */
  150. #define GREEN_SIZE              6
  151. #define BLUE_SIZE               7
  152. #define ALPHA_SIZE              8
  153. #define DEPTH_SIZE              9
  154. #define STENCIL_SIZE            10
  155. #define ACCUM_RED_SIZE          11  /* Used as mask bit for
  156.                                        "acc selected". */
  157. #define ACCUM_GREEN_SIZE        12
  158. #define ACCUM_BLUE_SIZE         13
  159. #define ACCUM_ALPHA_SIZE        14
  160. #define LEVEL                   15
  161.  
  162. #define NUM_GLXCAPS             (LEVEL + 1)
  163.  
  164. #define XVISUAL                 (NUM_GLXCAPS + 0)
  165. #define TRANSPARENT             (NUM_GLXCAPS + 1)
  166. #define SAMPLES                 (NUM_GLXCAPS + 2)
  167. #define XSTATICGRAY             (NUM_GLXCAPS + 3)  /* Used as
  168.                                                       mask bit
  169.                                                       for "any
  170.                                                       visual type
  171.                                                       selected". */
  172. #define XGRAYSCALE              (NUM_GLXCAPS + 4)
  173. #define XSTATICCOLOR            (NUM_GLXCAPS + 5)
  174. #define XPSEUDOCOLOR            (NUM_GLXCAPS + 6)
  175. #define XTRUECOLOR              (NUM_GLXCAPS + 7)
  176. #define XDIRECTCOLOR            (NUM_GLXCAPS + 8)
  177. #define SLOW                    (NUM_GLXCAPS + 9)
  178. #define CONFORMANT              (NUM_GLXCAPS + 10)
  179.  
  180. #define NUM_CAPS                (NUM_GLXCAPS + 11)
  181.  
  182. /* Frame buffer capablities that don't have a corresponding
  183.    FrameBufferMode entry.  These get used as mask bits. */
  184. #define NUM                     (NUM_CAPS + 0)
  185. #define RGBA_MODE               (NUM_CAPS + 1)
  186. #define CI_MODE                 (NUM_CAPS + 2)
  187. #define LUMINANCE_MODE        (NUM_CAPS + 3)
  188.  
  189. #define NONE            0
  190. #define EQ            1
  191. #define NEQ            2
  192. #define LTE            3
  193. #define GTE            4
  194. #define GT            5
  195. #define LT            6
  196. #define MIN            7
  197.  
  198. typedef struct _Criterion {
  199.   int capability;
  200.   int comparison;
  201.   int value;
  202. } Criterion;
  203.  
  204. typedef struct _FrameBufferMode {
  205.   XVisualInfo *vi;
  206. #if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_fbconfig)
  207.  
  208.   /* fbc is non-NULL when the XVisualInfo* is not OpenGL-capable
  209.      (ie, GLX_USE_GL is false), but the SGIX_fbconfig extension shows
  210.      the visual's fbconfig is OpenGL-capable.  The reason for this is typically
  211.      an RGBA luminance fbconfig such as 16-bit StaticGray that could
  212.      not be advertised as a GLX visual since StaticGray visuals are
  213.      required (by the GLX specification) to be color index.  The
  214.      SGIX_fbconfig allows StaticGray visuals to instead advertised as
  215.      fbconfigs that can provide RGBA luminance support. */
  216.  
  217.   GLXFBConfigSGIX fbc;
  218. #endif
  219.   int valid;
  220.   int cap[NUM_CAPS];
  221. } FrameBufferMode;
  222.  
  223. /* DisplayMode capability macros for game mode. */
  224. #define DM_WIDTH        0  /* "width" */
  225. #define DM_HEIGHT       1  /* "height" */
  226. #define DM_PIXEL_DEPTH  2  /* "bpp" (bits per pixel) */
  227. #define DM_HERTZ        3  /* "hertz" */
  228. #define DM_NUM          4  /* "num" */
  229.  
  230. #define NUM_DM_CAPS     (DM_NUM+1)
  231.  
  232. typedef struct _DisplayMode {
  233. #ifdef _WIN32
  234.   DEVMODE devmode;
  235. #else
  236.   /* XXX The X Window System does not have a standard
  237.      mechanism for display setting changes.  On SGI
  238.      systems, GLUT could use the XSGIvc (SGI X video
  239.      control extension).  Perhaps this can be done in
  240.      a future release of GLUT. */
  241. #endif
  242.   int valid;
  243.   int cap[NUM_DM_CAPS];
  244. } DisplayMode;
  245.  
  246. /* CALLBACK signature added to the following typedefs to provide for
  247.  * safe usage when glut is wrapped up in a MS Windows DLL and possibly
  248.  * used with code built with different default call sequences. Usage of
  249.  * CDECL preserves compatability with existing code.
  250.  *
  251.  * -tjump@spgs.com 6/25/98
  252.  *
  253.  * changed again 7/22/98 by taj to GLUTCALLBACK to prevent needing code
  254.  * changes yet to signify it's difference from the Win32 standard
  255.  * CALLBACK signature.
  256.  */
  257.  
  258. /* GLUT  function types */
  259. typedef void (GLUTCALLBACK *GLUTdisplayCB) (void);
  260. typedef void (GLUTCALLBACK *GLUTreshapeCB) (int, int);
  261. typedef void (GLUTCALLBACK *GLUTkeyboardCB) (unsigned char, int, int);
  262. typedef void (GLUTCALLBACK *GLUTmouseCB) (int, int, int, int);
  263. typedef void (GLUTCALLBACK *GLUTmotionCB) (int, int);
  264. typedef void (GLUTCALLBACK *GLUTpassiveCB) (int, int);
  265. typedef void (GLUTCALLBACK *GLUTentryCB) (int);
  266. typedef void (GLUTCALLBACK *GLUTvisibilityCB) (int);
  267. typedef void (GLUTCALLBACK *GLUTwindowStatusCB) (int);
  268. typedef void (GLUTCALLBACK *GLUTidleCB) (void);
  269. typedef void (GLUTCALLBACK *GLUTtimerCB) (int);
  270. typedef void (GLUTCALLBACK *GLUTmenuStateCB) (int);  /* DEPRICATED. */
  271. typedef void (GLUTCALLBACK *GLUTmenuStatusCB) (int, int, int);
  272. typedef void (GLUTCALLBACK *GLUTselectCB) (int);
  273. typedef void (GLUTCALLBACK *GLUTspecialCB) (int, int, int);
  274. typedef void (GLUTCALLBACK *GLUTspaceMotionCB) (int, int, int);
  275. typedef void (GLUTCALLBACK *GLUTspaceRotateCB) (int, int, int);
  276. typedef void (GLUTCALLBACK *GLUTspaceButtonCB) (int, int);
  277. typedef void (GLUTCALLBACK *GLUTdialsCB) (int, int);
  278. typedef void (GLUTCALLBACK *GLUTbuttonBoxCB) (int, int);
  279. typedef void (GLUTCALLBACK *GLUTtabletMotionCB) (int, int);
  280. typedef void (GLUTCALLBACK *GLUTtabletButtonCB) (int, int, int, int);
  281. typedef void (GLUTCALLBACK *GLUTjoystickCB) (unsigned int buttonMask, int x, int y, int z);
  282. #ifdef SUPPORT_FORTRAN
  283. typedef void (GLUTCALLBACK *GLUTdisplayFCB) (void);
  284. typedef void (GLUTCALLBACK *GLUTreshapeFCB) (int *, int *);
  285. /* NOTE the pressed key is int, not unsigned char for Fortran! */
  286. typedef void (GLUTCALLBACK *GLUTkeyboardFCB) (int *, int *, int *);
  287. typedef void (GLUTCALLBACK *GLUTmouseFCB) (int *, int *, int *, int *);
  288. typedef void (GLUTCALLBACK *GLUTmotionFCB) (int *, int *);
  289. typedef void (GLUTCALLBACK *GLUTpassiveFCB) (int *, int *);
  290. typedef void (GLUTCALLBACK *GLUTentryFCB) (int *);
  291. typedef void (GLUTCALLBACK *GLUTvisibilityFCB) (int *);
  292. typedef void (GLUTCALLBACK *GLUTwindowStatusFCB) (int *);
  293. typedef void (GLUTCALLBACK *GLUTidleFCB) (void);
  294. typedef void (GLUTCALLBACK *GLUTtimerFCB) (int *);
  295. typedef void (GLUTCALLBACK *GLUTmenuStateFCB) (int *);  /* DEPRICATED. */
  296. typedef void (GLUTCALLBACK *GLUTmenuStatusFCB) (int *, int *, int *);
  297. typedef void (GLUTCALLBACK *GLUTselectFCB) (int *);
  298. typedef void (GLUTCALLBACK *GLUTspecialFCB) (int *, int *, int *);
  299. typedef void (GLUTCALLBACK *GLUTspaceMotionFCB) (int *, int *, int *);
  300. typedef void (GLUTCALLBACK *GLUTspaceRotateFCB) (int *, int *, int *);
  301. typedef void (GLUTCALLBACK *GLUTspaceButtonFCB) (int *, int *);
  302. typedef void (GLUTCALLBACK *GLUTdialsFCB) (int *, int *);
  303. typedef void (GLUTCALLBACK *GLUTbuttonBoxFCB) (int *, int *);
  304. typedef void (GLUTCALLBACK *GLUTtabletMotionFCB) (int *, int *);
  305. typedef void (GLUTCALLBACK *GLUTtabletButtonFCB) (int *, int *, int *, int *);
  306. typedef void (GLUTCALLBACK *GLUTjoystickFCB) (unsigned int *buttonMask, int *x, int *y, int *z);
  307. #endif
  308.  
  309. typedef struct _GLUTcolorcell GLUTcolorcell;
  310. struct _GLUTcolorcell {
  311.   /* GLUT_RED, GLUT_GREEN, GLUT_BLUE */
  312.   GLfloat component[3];
  313. };
  314.  
  315. typedef struct _GLUTcolormap GLUTcolormap;
  316. struct _GLUTcolormap {
  317.   Visual *visual;       /* visual of the colormap */
  318.   Colormap cmap;        /* X colormap ID */
  319.   int refcnt;           /* number of windows using colormap */
  320.   int size;             /* number of cells in colormap */
  321.   int transparent;      /* transparent pixel, or -1 if opaque */
  322.   GLUTcolorcell *cells; /* array of cells */
  323.   GLUTcolormap *next;   /* next colormap in list */
  324. };
  325.  
  326. typedef struct _GLUTwindow GLUTwindow;
  327. typedef struct _GLUToverlay GLUToverlay;
  328. struct _GLUTwindow {
  329.   int num;              /* small integer window id (0-based) */
  330.  
  331.   /* Window system related state. */
  332. #if defined(_WIN32)
  333.   int pf;               /* pixel format */
  334.   HDC hdc;
  335. #endif
  336.   Window win;           /* X window for GLUT window */
  337.   GLXContext ctx;       /* OpenGL context GLUT glut window */
  338.   XVisualInfo *vis;     /* visual for window */
  339.   Bool visAlloced;      /* if vis needs deallocate on destroy */
  340.   Colormap cmap;        /* RGB colormap for window; None if CI */
  341.   GLUTcolormap *colormap;  /* colormap; NULL if RGBA */
  342.   GLUToverlay *overlay; /* overlay; NULL if no overlay */
  343.   Window renderWin;     /* X window for rendering (might be
  344.                            overlay) */
  345.   GLXContext renderCtx; /* OpenGL context for rendering (might
  346.                            be overlay) */
  347.   /* GLUT settable or visible window state. */
  348.   int width;            /* window width in pixels */
  349.   int height;           /* window height in pixels */
  350.   int cursor;           /* cursor name */
  351.   int visState;         /* visibility state (-1 is unknown) */
  352.   int shownState;       /* if window mapped */
  353.   int entryState;       /* entry state (-1 is unknown) */
  354. #define GLUT_MAX_MENUS              3
  355.  
  356.   int menu[GLUT_MAX_MENUS];  /* attatched menu nums */
  357.   /* Window relationship state. */
  358.   GLUTwindow *parent;   /* parent window */
  359.   GLUTwindow *children; /* list of children */
  360.   GLUTwindow *siblings; /* list of siblings */
  361.   /* Misc. non-API visible (hidden) state. */
  362.   Bool treatAsSingle;   /* treat this window as single-buffered
  363.                            (it might be "fake" though) */
  364.   Bool forceReshape;    /* force reshape before display */
  365. #if !defined(_WIN32)
  366.   Bool isDirect;        /* if direct context (X11 only) */
  367. #endif
  368.   Bool usedSwapBuffers; /* if swap buffers used last display */
  369.   long eventMask;       /* mask of X events selected for */
  370.   int buttonUses;       /* number of button uses, ref cnt */
  371.   int tabletPos[2];     /* tablet position (-1 is invalid) */
  372.   /* Work list related state. */
  373.   unsigned int workMask;  /* mask of window work to be done */
  374.   GLUTwindow *prevWorkWin;  /* link list of windows to work on */
  375.   Bool desiredMapState; /* how to mapped window if on map work
  376.                            list */
  377.   Bool ignoreKeyRepeat;  /* if window ignores autorepeat */
  378.   int desiredConfMask;  /* mask of desired window configuration
  379.                          */
  380.   int desiredX;         /* desired X location */
  381.   int desiredY;         /* desired Y location */
  382.   int desiredWidth;     /* desired window width */
  383.   int desiredHeight;    /* desired window height */
  384.   int desiredStack;     /* desired window stack */
  385.   /* Per-window GLUTCALLBACKs. */
  386.   GLUTdisplayCB display;  /* redraw */
  387.   GLUTreshapeCB reshape;  /* resize (width,height) */
  388.   GLUTmouseCB mouse;    /* mouse (button,state,x,y) */
  389.   GLUTmotionCB motion;  /* motion (x,y) */
  390.   GLUTpassiveCB passive;  /* passive motion (x,y) */
  391.   GLUTentryCB entry;    /* window entry/exit (state) */
  392.   GLUTkeyboardCB keyboard;  /* keyboard (ASCII,x,y) */
  393.   GLUTkeyboardCB keyboardUp;  /* keyboard up (ASCII,x,y) */
  394.   GLUTwindowStatusCB windowStatus;  /* window status */
  395.   GLUTvisibilityCB visibility;  /* visibility */
  396.   GLUTspecialCB special;  /* special key */
  397.   GLUTspecialCB specialUp;  /* special up key */
  398.   GLUTbuttonBoxCB buttonBox;  /* button box */
  399.   GLUTdialsCB dials;    /* dials */
  400.   GLUTspaceMotionCB spaceMotion;  /* Spaceball motion */
  401.   GLUTspaceRotateCB spaceRotate;  /* Spaceball rotate */
  402.   GLUTspaceButtonCB spaceButton;  /* Spaceball button */
  403.   GLUTtabletMotionCB tabletMotion;  /* tablet motion */
  404.   GLUTtabletButtonCB tabletButton;  /* tablet button */
  405. #ifdef _WIN32
  406.   GLUTjoystickCB joystick;  /* joystick */
  407.   int joyPollInterval; /* joystick polling interval */
  408. #endif
  409. #ifdef SUPPORT_FORTRAN
  410.   /* Special Fortran display  unneeded since no
  411.      parameters! */
  412.   GLUTreshapeFCB freshape;  /* Fortran reshape  */
  413.   GLUTmouseFCB fmouse;  /* Fortran mouse  */
  414.   GLUTmotionFCB fmotion;  /* Fortran motion  */
  415.   GLUTpassiveFCB fpassive;  /* Fortran passive  */
  416.   GLUTentryFCB fentry;  /* Fortran entry  */
  417.   GLUTkeyboardFCB fkeyboard;  /* Fortran keyboard  */
  418.   GLUTkeyboardFCB fkeyboardUp;  /* Fortran keyboard up */
  419.   GLUTwindowStatusFCB fwindowStatus;  /* Fortran visibility
  420.                                           */
  421.   GLUTvisibilityFCB fvisibility;  /* Fortran visibility
  422.                                       */
  423.   GLUTspecialFCB fspecial;  /* special key */
  424.   GLUTspecialFCB fspecialUp;  /* special key up */
  425.   GLUTbuttonBoxFCB fbuttonBox;  /* button box */
  426.   GLUTdialsFCB fdials;  /* dials */
  427.   GLUTspaceMotionFCB fspaceMotion;  /* Spaceball motion
  428.                                         */
  429.   GLUTspaceRotateFCB fspaceRotate;  /* Spaceball rotate
  430.                                         */
  431.   GLUTspaceButtonFCB fspaceButton;  /* Spaceball button
  432.                                         */
  433.   GLUTtabletMotionFCB ftabletMotion;  /* tablet motion
  434.                                        */
  435.   GLUTtabletButtonFCB ftabletButton;  /* tablet button
  436.                                        */
  437. #ifdef _WIN32
  438.   GLUTjoystickFCB fjoystick;  /* joystick */
  439. #endif
  440. #endif
  441. };
  442.  
  443. struct _GLUToverlay {
  444. #if defined(_WIN32)
  445.   int pf;
  446.   HDC hdc;
  447. #endif
  448.   Window win;
  449.   GLXContext ctx;
  450.   XVisualInfo *vis;     /* visual for window */
  451.   Bool visAlloced;      /* if vis needs deallocate on destroy */
  452.   Colormap cmap;        /* RGB colormap for window; None if CI */
  453.   GLUTcolormap *colormap;  /* colormap; NULL if RGBA */
  454.   int shownState;       /* if overlay window mapped */
  455.   Bool treatAsSingle;   /* treat as single-buffered */
  456. #if !defined(_WIN32)
  457.   Bool isDirect;        /* if direct context */
  458. #endif
  459.   int transparentPixel; /* transparent pixel value */
  460.   GLUTdisplayCB display;  /* redraw  */
  461.   /* Special Fortran display  unneeded since no
  462.      parameters! */
  463. };
  464.  
  465. typedef struct _GLUTstale GLUTstale;
  466. struct _GLUTstale {
  467.   GLUTwindow *window;
  468.   Window win;
  469.   GLUTstale *next;
  470. };
  471.  
  472. extern GLUTstale *__glutStaleWindowList;
  473.  
  474. #define GLUT_OVERLAY_EVENT_FILTER_MASK \
  475.   (ExposureMask | \
  476.   StructureNotifyMask | \
  477.   EnterWindowMask | \
  478.   LeaveWindowMask)
  479. #define GLUT_DONT_PROPAGATE_FILTER_MASK \
  480.   (ButtonReleaseMask | \
  481.   ButtonPressMask | \
  482.   KeyPressMask | \
  483.   KeyReleaseMask | \
  484.   PointerMotionMask | \
  485.   Button1MotionMask | \
  486.   Button2MotionMask | \
  487.   Button3MotionMask)
  488. #define GLUT_HACK_STOP_PROPAGATE_MASK \
  489.   (KeyPressMask | \
  490.   KeyReleaseMask)
  491.  
  492. typedef struct _GLUTmenu GLUTmenu;
  493. typedef struct _GLUTmenuItem GLUTmenuItem;
  494. struct _GLUTmenu {
  495.   int id;               /* small integer menu id (0-based) */
  496.   Window win;           /* X window for the menu */
  497.   GLUTselectCB select;  /*  function of menu */
  498.   GLUTmenuItem *list;   /* list of menu entries */
  499.   int num;              /* number of entries */
  500. #if !defined(_WIN32)
  501.   Bool managed;         /* are the InputOnly windows size
  502.                            validated? */
  503.   Bool searched;    /* help detect menu loops */
  504.   int pixheight;        /* height of menu in pixels */
  505.   int pixwidth;         /* width of menu in pixels */
  506. #endif
  507.   int submenus;         /* number of submenu entries */
  508.   GLUTmenuItem *highlighted;  /* pointer to highlighted menu
  509.                                  entry, NULL not highlighted */
  510.   GLUTmenu *cascade;    /* currently cascading this menu  */
  511.   GLUTmenuItem *anchor; /* currently anchored to this entry */
  512.   int x;                /* current x origin relative to the
  513.                            root window */
  514.   int y;                /* current y origin relative to the
  515.                            root window */
  516. #ifdef SUPPORT_FORTRAN
  517.   GLUTselectFCB fselect;  /*  function of menu */
  518. #endif
  519. };
  520.  
  521. struct _GLUTmenuItem {
  522.   Window win;           /* InputOnly X window for entry */
  523.   GLUTmenu *menu;       /* menu entry belongs to */
  524.   Bool isTrigger;       /* is a submenu trigger? */
  525.   int value;            /* value to return for selecting this
  526.                            entry; doubles as submenu id
  527.                            (0-base) if submenu trigger */
  528. #if defined(_WIN32)
  529.   UINT unique;          /* unique menu item id (Win32 only) */
  530. #endif
  531.   char *label;          /* __glutStrdup'ed label string */
  532.   int len;              /* length of label string */
  533.   int pixwidth;         /* width of X window in pixels */
  534.   GLUTmenuItem *next;   /* next menu entry on list for menu */
  535. };
  536.  
  537. typedef struct _GLUTtimer GLUTtimer;
  538. struct _GLUTtimer {
  539.   GLUTtimer *next;      /* list of timers */
  540.   struct timeval timeout;  /* time to be called */
  541.   GLUTtimerCB func;     /* timer  (value) */
  542.   int value;            /*  return value */
  543. #ifdef SUPPORT_FORTRAN
  544.   GLUTtimerFCB ffunc;   /* Fortran timer  */
  545. #endif
  546. };
  547.  
  548. typedef struct _GLUTeventParser GLUTeventParser;
  549. struct _GLUTeventParser {
  550.   int (*func) (XEvent *);
  551.   GLUTeventParser *next;
  552. };
  553.  
  554. /* Declarations to implement glutFullScreen support with
  555.    mwm/4Dwm. */
  556.  
  557. /* The following X property format is defined in Motif 1.1's
  558.    Xm/MwmUtils.h, but GLUT should not depend on that header
  559.    file. Note: Motif 1.2 expanded this structure with
  560.    uninteresting fields (to GLUT) so just stick with the
  561.    smaller Motif 1.1 structure. */
  562. typedef struct {
  563. #define MWM_HINTS_DECORATIONS   2
  564.   long flags;
  565.   long functions;
  566.   long decorations;
  567.   long input_mode;
  568. } MotifWmHints;
  569.  
  570. /* private variables from glut_event.c */
  571. extern GLUTwindow *__glutWindowWorkList;
  572. extern int __glutWindowDamaged;
  573. #ifdef SUPPORT_FORTRAN
  574. extern GLUTtimer *__glutTimerList;
  575. extern GLUTtimer *__glutNewTimer;
  576. #endif
  577. extern GLUTmenu *__glutMappedMenu;
  578.  
  579. extern void (*__glutUpdateInputDeviceMaskFunc) (GLUTwindow *);
  580. #if !defined(_WIN32)
  581. extern void (*__glutMenuItemEnterOrLeave)(GLUTmenuItem * item,
  582.   int num, int type);
  583. extern void (*__glutFinishMenu)(Window win, int x, int y);
  584. extern void (*__glutPaintMenu)(GLUTmenu * menu);
  585. extern void (*__glutStartMenu)(GLUTmenu * menu,
  586.   GLUTwindow * window, int x, int y, int x_win, int y_win);
  587. extern GLUTmenu * (*__glutGetMenuByNum)(int menunum);
  588. extern GLUTmenuItem * (*__glutGetMenuItem)(GLUTmenu * menu,
  589.   Window win, int *which);
  590. extern GLUTmenu * (*__glutGetMenu)(Window win);
  591. #endif
  592.  
  593. /* private variables from glut_init.c */
  594. extern Atom __glutWMDeleteWindow;
  595. extern Display *__glutDisplay;
  596. extern unsigned int __glutDisplayMode;
  597. extern char *__glutDisplayString;
  598. extern XVisualInfo *(*__glutDetermineVisualFromString) (char *string, Bool * treatAsSingle,
  599.   Criterion * requiredCriteria, int nRequired, int requiredMask, void **fbc);
  600. extern GLboolean __glutDebug;
  601. extern GLboolean __glutForceDirect;
  602. extern GLboolean __glutIconic;
  603. extern GLboolean __glutTryDirect;
  604. extern Window __glutRoot;
  605. extern XSizeHints __glutSizeHints;
  606. extern char **__glutArgv;
  607. extern char *__glutProgramName;
  608. extern int __glutArgc;
  609. extern int __glutConnectionFD;
  610. extern int __glutInitHeight;
  611. extern int __glutInitWidth;
  612. extern int __glutInitX;
  613. extern int __glutInitY;
  614. extern int __glutScreen;
  615. extern int __glutScreenHeight;
  616. extern int __glutScreenWidth;
  617. extern Atom __glutMotifHints;
  618. extern unsigned int __glutModifierMask;
  619.  
  620. /* private variables from glut_menu.c */
  621. extern GLUTmenuItem *__glutItemSelected;
  622. extern GLUTmenu **__glutMenuList;
  623. extern void (GLUTCALLBACK *__glutMenuStatusFunc) (int, int, int);
  624. extern void __glutMenuModificationError(void);
  625. extern void __glutSetMenuItem(GLUTmenuItem * item,
  626.   const char *label, int value, Bool isTrigger);
  627.  
  628. /* private variables from glut_win.c */
  629. extern GLUTwindow **__glutWindowList;
  630. extern GLUTwindow *__glutCurrentWindow;
  631. extern GLUTwindow *__glutMenuWindow;
  632. extern GLUTmenu *__glutCurrentMenu;
  633. extern int __glutWindowListSize;
  634. extern void (*__glutFreeOverlayFunc) (GLUToverlay *);
  635. extern XVisualInfo *__glutDetermineWindowVisual(Bool * treatAsSingle,
  636.   Bool * visAlloced, void **fbc);
  637.  
  638. /* private variables from glut_mesa.c */
  639. extern int __glutMesaSwapHackSupport;
  640.  
  641. /* private variables from glut_gamemode.c */
  642. extern GLUTwindow *__glutGameModeWindow;
  643.  
  644. /* private routines from glut_cindex.c */
  645. extern GLUTcolormap * __glutAssociateNewColormap(XVisualInfo * vis);
  646. extern void __glutFreeColormap(GLUTcolormap *);
  647.  
  648. /* private routines from glut_cmap.c */
  649. extern void __glutSetupColormap(
  650.   XVisualInfo * vi,
  651.   GLUTcolormap ** colormap,
  652.   Colormap * cmap);
  653. #if !defined(_WIN32)
  654. extern void __glutEstablishColormapsProperty(
  655.   GLUTwindow * window);
  656. extern GLUTwindow *__glutToplevelOf(GLUTwindow * window);
  657. #endif
  658.  
  659. /* private routines from glut_cursor.c */
  660. extern void __glutSetCursor(GLUTwindow *window);
  661.  
  662. /* private routines from glut_event.c */
  663. extern void __glutPutOnWorkList(GLUTwindow * window,
  664.   int work_mask);
  665. extern void __glutRegisterEventParser(GLUTeventParser * parser);
  666. extern void __glutPostRedisplay(GLUTwindow * window, int layerMask);
  667.  
  668. /* private routines from glut_init.c */
  669. #if !defined(_WIN32)
  670. extern void __glutOpenXConnection(char *display);
  671. #else
  672. extern void __glutOpenWin32Connection(char *display);
  673. #endif
  674. extern void __glutInitTime(struct timeval *beginning);
  675.  
  676. /* private routines for glut_menu.c (or win32_menu.c) */
  677. #if defined(_WIN32)
  678. extern GLUTmenu *__glutGetMenu(Window win);
  679. extern GLUTmenu *__glutGetMenuByNum(int menunum);
  680. extern GLUTmenuItem *__glutGetMenuItem(GLUTmenu * menu,
  681.   Window win, int *which);
  682. extern void __glutStartMenu(GLUTmenu * menu,
  683.   GLUTwindow * window, int x, int y, int x_win, int y_win);
  684. extern void __glutFinishMenu(Window win, int x, int y);
  685. #endif
  686. extern void __glutSetMenu(GLUTmenu * menu);
  687.  
  688. /* private routines from glut_util.c */
  689. extern char * __glutStrdup(const char *string);
  690. extern void __glutWarning(char *format,...);
  691. extern void __glutFatalError(char *format,...);
  692. extern void __glutFatalUsage(char *format,...);
  693.  
  694. /* private routines from glut_win.c */
  695. extern GLUTwindow *__glutGetWindow(Window win);
  696. extern void __glutChangeWindowEventMask(long mask, Bool add);
  697. extern XVisualInfo *__glutDetermineVisual(
  698.   unsigned int mode,
  699.   Bool * fakeSingle,
  700.   XVisualInfo * (getVisualInfo) (unsigned int));
  701. extern XVisualInfo *__glutGetVisualInfo(unsigned int mode);
  702. extern void __glutSetWindow(GLUTwindow * window);
  703. extern void __glutReshapeFunc(GLUTreshapeCB reshapeFunc,
  704.   int callingConvention);
  705. extern void  GLUTCALLBACK __glutDefaultReshape(int, int);
  706. extern GLUTwindow *__glutCreateWindow(
  707.   GLUTwindow * parent,
  708.   int x, int y, int width, int height, int gamemode);
  709. extern void __glutDestroyWindow(
  710.   GLUTwindow * window,
  711.   GLUTwindow * initialWindow);
  712.  
  713. #if !defined(_WIN32)
  714. /* private routines from glut_glxext.c */
  715. extern int __glutIsSupportedByGLX(char *);
  716. #endif
  717.  
  718. /* private routines from glut_input.c */
  719. extern void  __glutUpdateInputDeviceMask(GLUTwindow * window);
  720.  
  721. /* private routines from glut_mesa.c */
  722. extern void __glutDetermineMesaSwapHackSupport(void);
  723.  
  724. /* private routines from glut_gameglut.c */
  725. extern void CDECL __glutCloseDownGameMode(void);
  726.  
  727. #if defined(_WIN32)
  728. /* private routines from win32_*.c */
  729. extern LONG WINAPI __glutWindowProc(HWND win, UINT msg, WPARAM w, LPARAM l);
  730. extern HDC XHDC;
  731. extern HWND XHWND;
  732. #endif
  733.  
  734. #endif /* __glutint_h__ */
  735.